import request from '@/utils/request'
export default {
  /* 登录 */
  login(username,password){
    return request({
      url:`/testUser/login?username=${username}&password=${password}`,
      method:'get'
    })
  },
  /* 获取用户信息 */
  getUserInfo(id){
    return request({
        url:`/testUser/selectById/${id}`,
        method:'get',
  })
  },
  /* 注册接口 */
  addUser(pojo){
    return request({
      url:'/testUser/add',
      method:'post',
      data:pojo
    })
  },
  /* 发布热帖 */
  addTopic(pojo){
    return request({
      url:'/forum/add',
      method:'post',
      data:pojo
    })
  },
  /* 分页查询热帖 */
  querySelectHot(page,itemsPerPage,sort){
    return request({
      url:`/forum/select?page=${page}&itemsPerPage=${itemsPerPage}&sort=${sort}`,
      method:'get'
    })
  },
  /* 根据id查询热帖 */
  selectById(id){
    return request({
      url:`/forum/selectById/${id}`,
      method:'get'
    })
  },
  /* 评论/回复 */
  addComment(pojo){
    return request({
      url:'/forum/addComment',
      method:'post',
      data:pojo
    })
  },
  /* 删除评论 */
  deleteComment(id){
    return request({
      url:`/forum/deleteComment/${id}`,
      method:'delete'
    })
  },
  /* 根据热帖id查询评论 */
  selectCommentById(id,page,itemsPerPage){
    return request({
      url:`/forum/selectCommentById?page=${page}&itemsPerPage=${itemsPerPage}&id=${id}`,
      method:'get'
    })
  },
  /* 根据id查询我的评论 */
  selectMyCommentById(id,page,itemsPerPage){
    return request({
      url:`/forum/selectMyCommentByUid?page=${page}&itemsPerPage=${itemsPerPage}&id=${id}`
    })
  },
  /* 根据id查询他人回复 */
  selectOtherCommentById(id,page,itemsPerPage){
    return request({
      url:`/forum/selectOthersCommentByUid?page=${page}&itemsPerPage=${itemsPerPage}&id=${id}`,
      method:'get'
    })
  }
}